/**
 * 
 */
package fecat.ui.contextpanel.log;

import java.util.Vector;

import fecat.entities.NoticeModel;
import fecat.ui.contextpanel.table.SortTotalTableData;

/**
 * @author ibm
 *
 */
public class NoticeTableData  extends SortTotalTableData {
	public NoticeTableData() {
		m_vector = new Vector<NoticeModel>();
	}

	public void addRow(NoticeModel nm) {
		synchronized (m_vector) {
			m_vector.addElement(nm);
			m_vector.notifyAll();
		}
	}
	public void removeRowByMessageId(String messageId){
		synchronized (m_vector) {
			for(int i=0;i<m_vector.size();i++){
				NoticeModel notice = (NoticeModel) m_vector.elementAt(i);
				if(notice.getMessageId().equals(messageId)){
					m_vector.remove(i);
					break;
				}
			}
			m_vector.notifyAll();
		}
	}
	public Object getValueAt(int nRow, int nCol) {
		if (nRow < 0 || nRow >= getRowCount())
			return "";
		if(nRow<m_vector.size()){
			NoticeModel notice = (NoticeModel) m_vector.elementAt(nRow);
			
			switch (nCol) {
			case 0:
				return notice.getTitle();
			case 1:
				return notice.getMessage();
			case 2:
				return notice.getEndTime();
			}
		}
		return "";
	}
}
